import { fileURLToPath, URL } from 'node:url'
import AutoImport from 'unplugin-auto-import/vite'
import veauryVitePlugins from 'veaury/vite/index.js'
import { defineConfig } from 'vite'

import InjectContextNamePlugin from './vite-plugin-inject-context-name'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // UnoCSS(),
    InjectContextNamePlugin(),
    AutoImport({
      imports: ['vue', 'vue-router', 'vue-i18n'],
      dts: './types/auto-imports.d.ts',
      eslintrc: {
        enabled: true,
        filepath: './types/.eslintrc-auto-import.json',
        globalsPropValue: true,
      },
    }),
    AutoImport({
      dirs: ['./src/components/**'],
      dts: './types/auto-import-components.d.ts',
    }),
    // vue(),
    // vueJsx(),
    veauryVitePlugins({
      type: 'vue',
      vueJsxOptions: {
        exclude: [/[/\\]antd-materials[\\/$]+/],
      },
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server: {
    port: 9002,
  },
})
